package com.blb.common.feign;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.blb.common.entity.Product;
import com.blb.common.util.ResponseResult;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

/**
 * 调用商品服务的Feign客户端
 * @FeignClient需要设置调用的服务名
 */
@FeignClient(value = "product-service",fallback = ProductServiceFeignClientFallback.class)
public interface ProductServiceFeignClient {

    /**
     * 调用商品id查询
     * @param id
     * @return
     */
    @GetMapping("/product/{id}")
    ResponseResult<Product> getProductById(@PathVariable Long id);

    @GetMapping("/product")
    ResponseResult<Product> getProductById2(@RequestParam Long id);

    @PostMapping("/product")
    ResponseResult<String> saveProduct(@RequestBody Product product);

    @PutMapping("/product")
    ResponseResult<String> updateProduct(@RequestBody Product product);

    @DeleteMapping("/product/{id}")
    ResponseResult<String> updateProduct(@PathVariable Long id);

    @GetMapping("/product/page")
    ResponseResult<Page<Product>> getProductPage(@RequestParam Long current);
}
